﻿<?php

class Connexion
{
	//login (mail adress)
	var $login;

	public static function createConnexion($email, $password)
	{
		$q = new ClientQuery();
		$client = $q->findOneByEmail($email);
		if($client != null)
		{
			if($client->getPassword() == md5($password))
			{
				$conn = new Connexion();
				$conn->login = $client->getEmail();
				$_SESSION['connexion'] = serialize($conn);
				$_COOKIE['mail'] = $client->getEmail();
				setCookie("cookie", $client->getEmail(), time()+31536000);
				return true;
			}
			
		}
		return false;
	}


}
